home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / education / pe023.dms / pe023.adf / ALGORHYTHMS / SOURCE / WINDOW.C < prev    next >
C/C++ Source or Header  |  1988-10-05  |  3KB  |  113 lines

  1. /* window.c */
  2. /* Copyright 1990 Thomas E. Janzen All Rights Reserved */
  3. /*
  4. **  FACILITY:
  5. **
  6. **    AlgoRhythms music improviser on Commodore (TM) Amiga (TM)
  7. **    compiled with Lattice (TM) C 5.05
  8. **
  9. **  ABSTRACT:
  10. **
  11. **    Algorhythms improvises music over the MIDI serial port.
  12. **
  13. **  AUTHORS: Thomas E. Janzen
  14. **
  15. **  CREATION DATE:    26-MAR-1990
  16. **
  17. **  MODIFICATION HISTORY:
  18. **    DATE    NAME    DESCRIPTION
  19. **--
  20. */
  21. #include <exec/types.h>
  22. #include <exec/nodes.h>
  23. #include <exec/lists.h>
  24. #include <intuition/intuition.h>
  25. #include <graphics/text.h>
  26. #include <proto/exec.h>
  27. #include <proto/graphics.h>
  28. #include <proto/intuition.h>
  29. #include <proto/dos.h>
  30. #include <proto/mathffp.h>
  31. #include <math.h>
  32. #include <stdlib.h>
  33.  
  34. void OpenWind(void);
  35. void OpenLibs(void);
  36. void CloseLibs(void);
  37. void OpenWind(void);
  38. void MakeWindow(void);
  39.  
  40. struct IntuitionBase *IntuitionBase;
  41. struct GfxBase *GfxBase;
  42. struct DOSBase *DOSBase;
  43. struct MathBase *MathBase;
  44.  
  45. ULONG class,classb;    /* Intu Event class */
  46. USHORT code,codeb;    /* Intu Event code */
  47.  
  48. /*WINDOW*/
  49. struct Window *w;
  50. struct RastPort *rp;
  51. struct ViewPort *vp;
  52. struct IntuiMessage *message;
  53.  
  54. void MakeWindow(void) {
  55.     OpenLibs();
  56.     OpenWind();
  57. }
  58.  
  59. void OpenWind(void) {
  60.     struct NewWindow nw = {
  61.     0,10,400,100,    /* Left, Top, Width, height */
  62.     2,1,         /* detail, block pens */
  63.     NEWSIZE|CLOSEWINDOW|MENUPICK|GADGETUP|REQCLEAR,    /* IDCMP flags */
  64.     WINDOWSIZING|WINDOWDRAG|SMART_REFRESH|WINDOWDEPTH|
  65.     WINDOWCLOSE|GIMMEZEROZERO,
  66.     NULL,            /* Pointer to first gadget */
  67.     NULL,            /* Pointer to checkmark */
  68.     "AlgoRhythms",        /* title */
  69.     NULL,            /* screen pointer */
  70.     NULL,            /* bitmap pointer */
  71.     400,100,640,190,    /* window not sized */
  72.     WBENCHSCREEN        /* type of screen */
  73. };
  74.     w = OpenWindow(&nw);
  75.     rp = w->RPort;            /* Get the raster port pointer */
  76.     vp = &w->WScreen->ViewPort;    /* Get the view port pointer */
  77. }
  78.  
  79. void OpenLibs(void) {
  80.     if(!(IntuitionBase=
  81.     (struct IntuitionBase *)OpenLibrary("intuition.library",0L))) {
  82.         CloseLibs();
  83.         exit(FALSE);
  84.     }
  85.     if(!(GfxBase = 
  86.     (struct GfxBase *)OpenLibrary("graphics.library",0L))) {
  87.         CloseLibs();
  88.         exit(FALSE);
  89.     }
  90.     if(!(MathBase = 
  91.     (struct MathBase *)OpenLibrary("mathffp.library",0L))) {
  92.         CloseLibs();
  93.         exit(FALSE);
  94.     }
  95.     if(!(DOSBase = 
  96.     (struct DOSBase *)OpenLibrary("dos.library",0L))) {
  97.         CloseLibs();
  98.         exit(FALSE);
  99.     }
  100. }
  101.  
  102. void CloseLibs(void) {
  103.         if(GfxBase) CloseLibrary(GfxBase);
  104.         if(IntuitionBase) CloseLibrary(IntuitionBase);
  105.         if(MathBase) CloseLibrary(MathBase);
  106.         if(DOSBase) CloseLibrary(DOSBase);
  107. }
  108.  
  109. void ShutWindow(void) {
  110.     CloseLibs();
  111.     CloseWindow(w);
  112. }
  113.